﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using StackExchange.Redis;

namespace RedisDemo.Services
{
    public class RedisTestService
    {
        private readonly RedisManager _redisManager;

        public RedisTestService(RedisManager redisManager)
        {
            _redisManager = redisManager;
        }

        public async Task Test()
        {
            var db = _redisManager.GetDatabase();

            var success = await db.StringSetAsync("Hello", "World1", TimeSpan.FromSeconds(10), When.NotExists);

            await db.StringSetAsync("Count", 1);
            await db.StringIncrementAsync("Count", 3);
            await db.StringDecrementAsync("Count", 1);

            var hello = await db.StringGetAsync("Hello");

            var mylist = await db.ListRangeAsync("mylist");
        }
    }
}
